package com.flume.sample

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.water.spout.FlumeLayout

/**
 *  Created by zxn on 2021/11/15.
 */
class FlumeActivity : AppCompatActivity() {

    companion object {
        @JvmStatic
        fun jumpTo(context: Context) {
            context.startActivity(Intent(context, FlumeActivity::class.java))
        }
    }

    private val flumeLayout by lazy {
        findViewById<FlumeLayout>(R.id.flumeLayout)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_flume)

        //mHeight:1647
        //951

        /*flumeLayout.post {
            Log.i("FlumeActivity", "onCreate: height:${flumeLayout.height}")
            val result =  flumeLayout.height - dp2px(this,6F*2)
            Log.i("FlumeActivity", "onCreate: imageH:$result")
        }*/

        flumeLayout.let {
            //it.setSpoutResource(R.mipmap.ic_spout_bg_new)
            //it.show(500, 2000)
            //it.show(250, 2000)
            //it.show(125, 2000)
            //it.show(60, 2000)
            //it.show(20, 2000)
            //it.show(2000, 2000)
            //it.show(1500, 2000)
            //it.show(2000, 2000)
        }

        findViewById<View>(R.id.btnFull).setOnClickListener {
            flumeLayout.show(5000, 5000)
        }

        findViewById<View>(R.id.btnHalf).setOnClickListener {
            flumeLayout.show(1500, 3000)
        }

        findViewById<View>(R.id.btnClear).setOnClickListener {
            flumeLayout.show(0, 2000)
        }

        flumeLayout.setOnFlumeChangeListener { value, volume ->
            Log.i("FlumeActivity", "onCreate:value: $value,volume: $volume")
        }

    }
}